<?php

namespace App\Models;

use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;

class Banner extends Model
{

    public function getImgUrlAttribute()
    {
        // 如果 image 字段本身就已经是完整的 url 就直接返回
        if (Str::startsWith($this->attributes['img_url'], ['http://', 'https://'])) {
            return $this->attributes['img_url'];
        }
        return \Storage::disk('admin')->url($this->attributes['img_url']);
    }
}
